package logicapi

import (
	"GO_BACK/utils"
	"fmt"
	"gopkg.in/gomail.v2"
)

func SendEmail(email string) (error, string) {
	verificationCode := utils.GenerateCode()
	mail := gomail.NewMessage()
	mail.SetHeader("From", "320046320@qq.com") // 发件人
	mail.SetHeader("To", email)                // 收件人
	mail.SetHeader("Subject", "注册验证码")
	mail.SetBody("text/plain", fmt.Sprintf("您的验证码是: %s,验证码五分钟内有效", verificationCode)) // 邮件主题
	d := gomail.NewDialer("smtp.qq.com", 587, "320046320@qq.com", "hewpbyfjmyplbhac")
	err := d.DialAndSend(mail)
	return err, verificationCode
}
